<?php 
Class goodsController extends appController
{
	public function glist()
	{
	    
		$args['cat_id']=$_GET['id'];
		$args['page']=isset($_REQUEST['page'])?intval($_REQUEST['page']):1;
		$args['page_size']=8;
		$cache_id = $args['page']. '-' .$_GET['id'] . '-' .$_GET['k']. '-' .DEFAULT_LANG. '-' .session('user_id');
		$args['keyword']=base64_decode($_GET['k']);
		$cache_id = sprintf('%X', crc32($cache_id));
		if (!$this->is_cached('list.html', $cache_id))
		{
			$app=Model('app');
			$goods=Model('goods');
			$cat=$app->getTopClass($args['cat_id']);
			$this->assign('top',$cat);
			$cat=$app->getCurClass($args['cat_id']);
			$this->assign('cat',$cat);
			$config[c]=array('site_name'=>$cat['name'].'-'.$app->get_cfg('site_name'));
			$this->assign_global($config);
			$art_list=$goods->get_goods_list($args);
		$this->assign('goods_list',$art_list['data']);
		$this->assign('art_page',$art_list['pagelink']);
		
		}
		
		$this->display('list.html',$cache_id);
	}
	public function search()
	{
		$key=trim($_POST['keywords']);
		header('Location:http://'.$_SERVER['HTTP_HOST'].'/goods/list.html?k='.base64_encode($key));
	   exit;
	}

	public function view()
	{
		$id=isset($_GET['id'])?intval($_GET['id']):'';
		$cache_id = $id . '-' . DEFAULT_LANG. '-' .session('user_id');;
		$goods=Model('goods');
		
		
		
		$cache_id = sprintf('%X', crc32($cache_id));
		if (!$this->is_cached('goods.html', $cache_id))
		{
		
		//$cat_id=Model('article')->article_cat($id);
		//关联商品
		$links=$goods->get_link_goods($id);
		$this->assign('link_goods',$links);
		$art_info=$goods->get_good($id);
		
		
		$app=Model('app');
		$config[c]=array('site_name'=>$art_info['title'].'-'.$app->get_cfg('site_name'));
		$this->assign_global($config);
		
		$this->assign('art_cat',$art_cat);
		$this->assign('goods',$art_info);
		
		}
		
		
		$this->display('goods.html', $cache_id);
	}

	
	

	
	
}